<%-- 
    Document   : adminhomepage
    Created on : Aug 4, 2013, 9:10:31 AM
    Author     : Thien Nguyen
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<head>
    <link href="css/css/bootstrap.css" rel="stylesheet" type="text/css" />
    <link href="css/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
</head>
<jsp:include page="header3.jsp"/>
<c:if test="${type eq 'artist'}">
    <h1>Quản lý ca sĩ</h1><br/>
    <td><a href="ControllerServlet?btnAction=Add&type=artist">Thêm ca sĩ</a></td>
    <table border="1" class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Tên ca sĩ</th>
                <th></th>

            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${LIST}">
            <form action="ControllerServlet">
                <tr>
                    <td>
                        ${item.artistID}
                        <input type="hidden" name="type" value="artist" />
                        <input type="hidden" name="id" value="${item.artistID}" />
                    </td>
                    <td>${item.artistName}</td>
                    
                    <td><input type="submit" value="Delete" name="btnAction" onclick="return getValue();" class="btn btn-default"/></td>
                </tr>
            </form>
        </c:forEach>
    </tbody>
</table>
</c:if>
<c:if test="${type eq 'producer'}">
    <h1>Quản lý nhà sản xuất</h1><br/>
    <td><a href="ControllerServlet?btnAction=Add&type=producer">Thêm nhà sản xuất</a></td>
    <table border="1" class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Tên nhà sản xuất</th>
                <th></th>

            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${LIST}">
            <form action="ControllerServlet">
                <tr>
                    <td>
                        ${item.producerID}
                        <input type="hidden" name="type" value="producer" />
                        <input type="hidden" name="id" value="${item.producerID}" />
                    </td>
                    <td>${item.producerName}</td>
                    
                    <td><input type="submit" value="Delete" name="btnAction" onclick="return getValue();" class="btn btn-default"/></td>
                </tr>
            </form>
        </c:forEach>
    </tbody>
</table>
</c:if>
<c:if test="${type eq 'album'}">
    <h1>Quản lý album</h1><br/>
    <td><a href="ControllerServlet?btnAction=Add&type=album">Thêm album</a></td>
    <table border="1" class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Tên album</th>
                <th>Hình ảnh URL</th>
                <th></th>
                <th></th>

            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${LIST}">
            <form action="ControllerServlet">
                <tr>
                    <td>
                        ${item.albumID}
                        <input type="hidden" name="type" value="album" />
                        <input type="hidden" name="id" value="${item.albumID}" />
                    </td>
                    <td>${item.albumName}</td>
                    <td>${item.imageUrl}</td>
                    
                    <td><a href="ControllerServlet?btnAction=Edit&type=album&id=${item.albumID}">Sửa thông tin</a></td>
                    <td><input type="submit" value="Delete" name="btnAction" onclick="return getValue();" class="btn btn-default"/></td>
                </tr>
            </form>
        </c:forEach>
    </tbody>
</table>
</c:if>
<c:if test="${type eq 'country'}">
    <h1>Quản lý quốc gia</h1><br/>
    <td><a href="ControllerServlet?btnAction=Add&type=country">Thêm quốc gia</a></td>
    <table border="1" class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Tên quốc gia</th>
                <th></th>

            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${LIST}">
            <form action="ControllerServlet">
                <tr>
                    <td>
                        ${item.countryID}
                        <input type="hidden" name="type" value="country" />
                        <input type="hidden" name="id" value="${item.countryID}" />
                    </td>
                    <td>${item.countryName}</td>
                    
                    <td><input type="submit" value="Delete" name="btnAction" onclick="return getValue();" class="btn btn-default"/></td>
                </tr>
            </form>
        </c:forEach>
    </tbody>
</table>
</c:if>
<c:if test="${type eq 'genre'}">
    <h1>Quản lý thể loại</h1><br/>
    <td><a href="ControllerServlet?btnAction=Add&type=genre">Thêm thể loại</a></td>
    <table border="1" class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Tên thể loại</th>
                <th></th>

            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${LIST}">
            <form action="ControllerServlet">
                <tr>
                    <td>
                        ${item.genreID}
                        <input type="hidden" name="type" value="genre" />
                        <input type="hidden" name="id" value="${item.genreID}" />
                    </td>
                    <td>${item.genreName}</td>
                    
                    <td><input type="submit" value="Delete" name="btnAction" onclick="return getValue();" class="btn btn-default"/></td>
                </tr>
            </form>
        </c:forEach>
    </tbody>
</table>
</c:if>
<c:if test="${type eq 'musician'}">
    <h1>Quản lý nhạc sĩ</h1><br/>
    <td><a href="ControllerServlet?btnAction=Add&type=musician">Thêm nhạc sĩ</a></td>
    <table border="1" class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Tên nhạc sĩ</th>
                <th></th>
                
            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${LIST}">
            <form action="ControllerServlet">
                <tr>
                    <td>
                        ${item.musicianID}
                        <input type="hidden" name="type" value="musician" />
                        <input type="hidden" name="id" value="${item.musicianID}" />
                    </td>
                    <td>${item.musicianName}</td>
                    
                    <td><input type="submit" value="Delete" name="btnAction" onclick="return getValue();" class="btn btn-default"/></td>
                </tr>
            </form>
        </c:forEach>
    </tbody>
</table>
</c:if>
<c:if test="${type eq 'comment'}">
    <h1>Quản lý bình luận</h1><br/>
    <table border="1" class="table table-striped">
           <thead>
            <tr>
                <th>ID</th>
                <th>Tên người bình luận</th>
                <th>Ngày bình luận</th>
                <th>Nội dung bình luận</th>
                <th>Bài hát bình luận</th>
                <th></th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${LIST}">
            <form action="ControllerServlet">
                <tr>
                    <td>
                        ${item.commentID}
                        <input type="hidden" name="type" value="comment" />
                        <input type="hidden" name="id" value="${item.commentID}" />
                    </td>
                    <td>${item.username}</td>
                    <td>${item.commentDate}</td>
                    <td>${item.content}</td>
                    <td>${item.songs.name}</td>
                    <td><a href="ControllerServlet?btnAction=Edit&type=comment&id=${item.commentID}">Sửa thông tin</a></td>
                    <td><input type="submit" value="Delete" name="btnAction" onclick="return getValue();" class="btn btn-default"/></td>
                </tr>
            </form>
        </c:forEach>
    </tbody>
</table>
</c:if>
<c:if test="${type eq 'user'}">
    <h1>Quản lý người dùng</h1><br/>
    <td><a href="ControllerServlet?btnAction=Add&type=user">Thêm người dùng</a></td>
    <table border="1" class="table table-striped">
        <thead>
            <tr>
                <th>Tên người dùng</th>
                <th>Mật khẩu</th>
                <th>Ngày tạo</th>
                <th>Email</th>
                <th>Vai trò</th>
                <th>Đã tải lên</th>
                <th></th>
                <th></th>

            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${LIST}">
            <form action="ControllerServlet">
                <tr>
                    <td>
                        ${item.username}
                        <input type="hidden" name="type" value="user" />
                        <input type="hidden" name="id" value="${item.username}" />
                    </td>
                    <td>${item.password}</td>
                    <td>${item.createdDate}</td>
                    <td>${item.email}</td>
                    <td>
                        <c:if test="${item.isAdmin eq true}">Admin</c:if>
                        <c:if test="${item.isAdmin eq false}">Người dùng</c:if>
                    </td>
                    <td>${item.uploaded}</td>
                    
                    <td><a href="ControllerServlet?btnAction=Edit&type=user&id=${item.username}">Sửa thông tin</a></td>
                    <td><input type="submit" value="Delete" name="btnAction" onclick="return getValue();" class="btn btn-default"/></td>
                </tr>
            </form>
        </c:forEach>
    </tbody>
</table>
</c:if>
<c:if test="${type eq 'song'}">
    <h1>Quản lý bài hát</h1><br/>
    <td><a href="ControllerServlet?btnAction=Add&type=song">Thêm bài hát</a></td>
    <table border="1" class="table table-striped">
        <thead>
            <tr>
                <th>ID</th>
                <th>Tên bài hát</th>
                <th></th>
                <th></th>
                <th></th>
            </tr>
        </thead>
        <tbody>
            <c:forEach var="item" items="${LIST}">
            <form action="ControllerServlet">
                <tr>
                    <td>
                        ${item.songID}
                        <input type="hidden" name="type" value="song" />
                        <input type="hidden" name="id" value="${item.songID}" />
                    </td>
                    <td>${item.name}</td>
                    <td><a href="ControllerServlet?btnAction=View&type=song&id=${item.songID}">Xem thông tin</a></td>
                    <td><a href="ControllerServlet?btnAction=Edit&type=song&id=${item.songID}">Sửa thông tin</a></td>
                    <td><input type="submit" value="Delete" name="btnAction" onclick=" return getValue();" class="btn btn-default"/></td>
                </tr>
            </form>
        </c:forEach>
    </tbody>
</table>
</c:if>
<jsp:include page="footer.jsp"/>
<script type="text/javascript">
    <!--
    function getValue(){
        if(confirm("Bạn có muốn xóa thông tin này?"))
        {
            window.location = "ControllerServlet";
            return true;
        }
        return false;
    }
    //-->
</script>